<?
include "include/config.php";
	
        
$tip=array ('1'=>'Garsoniera','2'=>'Apartament 2 camere','3'=>'Apartament 3 camere','4'=>'Apartament 4 camere','5'=>'Teren','6'=>'Spatiu Comercial','7'=>'Casa/Vila');
$oferta=array ('1'=>'Vanzare','2'=>'Inchiriere');
$smarty->assign('tip',$tip);
$smarty->assign('oferta',$oferta);

$user_mod_query=mysql_query("select id,name from users where level=10 ");
$agents["0"]="Alegeti agent";	
        while ($users=mysql_fetch_array($user_mod_query)) {
            $agents[$users["id"]] =$users["name"];
        }
$smarty->assign('agent',$agents);

$valuta=array ('0'=>'Discutabil','1'=>'RON','2'=>'EURO','3'=>'USD'); 
$smarty->assign('valuta',$valuta); 
	
 $_query = mysql_query("select oferta.*,locatii.name,parent.name as parent,parent.id as parentid, users.name as user_name, telefon,functie, img, user_id
                                        from        oferta 
                                        left join locatii on oferta.id_loc=locatii.id 
                                        left join locatii as parent on parent.id=locatii.id_parent
                                        inner join users  on oferta.user_id=users.id
    
                                         where spof=1 ORDER BY ID DESC LIMIT 0,15 " );
   while ($cereri_array=mysql_fetch_array($_query))
     {
         list($idp,$numep)=mysql_fetch_array(mysql_query("select L0.id,L0.name from locatii L0
                                                         left join locatii L1 on L1.id_parent=L0.id
                                                         where L1.id='".$cereri_array['parentid']."'   ")); 
         
         $img_rows=mysql_fetch_row(mysql_query("select id,src from imagini
                                                                         where id_oferta='".$cereri_array['id']."' "));
        if ($img_rows["0"]!="") {
                $cereri_array['src']=$img_rows["1"];
        }         
         if ($idp!='') $cereri_array['parent']=$numep;
         $_data[]=$cereri_array;
     }    
	
//print_r ($oferta_spof);
$smarty->assign('oferte',$_data);
$smarty->assign("content", $smarty->fetch(tmpd.'spof'.tmpl_ext));
include "include/make_page.php";
?>
